project(Rubik)

if (MINGW)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/MINGW/)
endif (MINGW)
if (UNIX)
    set(CMAKE_CXX_COMPILER /D/Linux/clang+llvm-4.0.0-x86_64-linux-gnu-debian8/bin/clang++)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/LINUX/)
endif (UNIX)

# FIND OPENGL
find_package(OpenGL REQUIRED)
set(Rubik_INCDIR ${OpenGL_INCLUDE_DIRS})
set(Rubik_LNKDIR ${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
if (NOT OPENGL_FOUND)
    message(ERROR 'OPENGL not found!')
endif (NOT OPENGL_FOUND)

set(Rubik_INCDIR
        ${CMAKE_CURRENT_SOURCE_DIR})

include_directories(${Rubik_INCDIR})

add_executable(Rubik
        Cube.cpp Cube.h Rubik.cpp Rubik.h Game.cpp Game.h stdafx.h main.cpp
        sdl_scancode_to_dinput_mappings.h)

if (MSVC)
    link_directories(depths/MSVC)

    target_link_libraries(Rubik
            ZainGL
            ZainTL
            #[[CEGUI]]
            CEGUIOpenGLRenderer-0
            CEGUIBase-0
            #[[===========]]
            assimp
            SOIL
            glew32
            SDL2
            #[[======Bullet=====]]
            BulletDynamics
            BulletCollision
            LinearMath
            ${OPENGL_LIBRARIES})
endif ()
if (MINGW)
    include_directories(
            ../ZainGL
            ../ZainTL)

    find_library(ZainGL_PATH ZainGL depths/MINGW)
    find_library(ZainTL_PATH ZainTL depths/MINGW)
    find_library(CEGUIOpenGLRenderer_PATH CEGUIOpenGLRenderer-0 depths/MINGW)
    find_library(CEGUIBase_PATH CEGUIBase-0 depths/MINGW)
    find_library(assimp_PATH assimp depths/MINGW)
    find_library(SOIL_PATH SOIL depths/MINGW)
    find_library(glew_PATH glew depths/MINGW)
    find_library(SDL2_PATH SDL2 depths/MINGW)
    find_library(BulletDynamics_PATH BulletDynamics depths/MINGW)
    find_library(BulletCollision_PATH BulletCollision depths/MINGW)
    find_library(LinearMath_PATH LinearMath depths/MINGW)

    target_link_libraries(Rubik
            #[[${ZainGL_PATH}
            ${ZainTL_PATH}]]
            ZainGL
            ZainTL
            #[[CEGUI]]
            ${CEGUIOpenGLRenderer_PATH}
            ${CEGUIBase_PATH}
            #[[===========]]
            ${assimp_PATH}
            ${SOIL_PATH}
            ${glew_PATH}
            #[[=======以下是SDL需要的库====]]
            ${SDL2_PATH}
            mingw32
            m
            dinput8
            dxguid
            dxerr8
            user32
            gdi32
            winmm
            imm32
            ole32
            oleaut32
            shell32
            version
            uuid
            #[[======Bullet=====]]
            ${BulletDynamics_PATH}
            ${BulletCollision_PATH}
            ${LinearMath_PATH}
            ${OPENGL_LIBRARIES})
endif ()
if (UNIX)
    include_directories(
            ../ZainGL
            ../ZainTL
    )
    find_library(GLEW_PATH GLEW depths/Linux)
    find_library(CEGUIOpenGLRenderer_PATH
            CEGUIOpenGLRenderer-0 depths/Linux)
    find_library(CEGUIBase_PATH CEGUIBase-0 depths/Linux)
    find_library(assimp_PATH assimpd depths/Linux)
    find_library(SOIL_PATH SOIL depths/Linux)
    find_library(SDL2_PATH SDL2 depths/Linux)
    find_library(BulletDynamics_PATH BulletDynamics depths/Linux)
    find_library(BulletCollision_PATH BulletCollision depths/Linux)
    find_library(LinearMath_PATH LinearMath depths/Linux)

    target_link_libraries(Rubik
            #[[${ZainGL_PATH}
            ${ZainTL_PATH}]]
            ZainGL
            ZainTL
            ${GLEW_PATH}
            #[[CEGUI]]
            ${CEGUIOpenGLRenderer_PATH}
            ${CEGUIBase_PATH}
            #[[===========]]
            ${assimp_PATH}
            ${SOIL_PATH}
            #[[=======SDL====]]
            ${SDL2_PATH}
            #[[======Bullet=====]]
            ${BulletDynamics_PATH}
            ${BulletCollision_PATH}
            ${LinearMath_PATH}
            ${OPENGL_LIBRARIES}
            #[[other]]
            dl
            pthread
            )
endif (UNIX)

set_target_properties(Rubik PROPERTIES LINKER_LANGUAGE CXX)